package com.mapper;

import com.pojo.Admin;
import com.pojo.Teacher;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Select;
import org.apache.ibatis.annotations.Update;

import java.util.List;

@Mapper
public interface UserMapper {

    @Select("select * from teacher where open_id = #{openId}")
    Teacher getTeacherByOpenId(String openId);

    @Select("select * from admin where open_id = #{openId}")
    Admin getAdminByOpenId(String openId);

    @Update("update admin set avatar = #{avatar} where open_id = #{id}")
    void updateAdminAvatar(String open_id,String avatar);

    @Update("update teacher set avatar = #{avatar} where open_id = #{id}")
    void updateTeacherAvatar(String oprn_id,String avatar);
    /********************分界线**********************/
    @Select("select * from admin where id = #{id}")
    Admin getAdminById(Integer id);

    @Select("select * from teacher where id = #{id}")
    Teacher getTeacherById(Integer id);

    @Select("select * from admin where nickname = #{name}")
    List<Admin> getAdminByName(String name);

    @Update("update admin set nickname = #{name} where id = #{id}")
    void editAdminName(Integer id,String name);

    @Update("update teacher set name = #{name} where id = #{id}")
    void editTeacherName(Integer id,String name);

    @Select("select * from admin where account = #{account}")
    Admin getAdminByAccount(String account);

    @Select("select * from teacher where account = #{account}")
    Teacher getTeacherByAccount(String account);

    @Update("update admin set account = #{account} where id = #{id}")
    void updateAdminAccount(Integer id,String account);

    @Update("update teacher set account = #{account} where id = #{id}")
    void updateTeacherAccount(Integer id,String account);



    @Select("select name from station where id = #{id}")
    String getStationNameById(Integer id);

    @Update("update admin set loginTime = Now() where id = #{id}")
    void upAdminLoginTime(Integer id);

    @Update("update teacher set loginTime = Now() where id = #{id}")
    void upTeacherLoginTime(Integer id);

    @Update("update admin set password = #{password} where id = #{id}")
    void upAdminPassword(Integer id,String password);

    @Update("update teacher set password = #{password} where id = #{id}")
    void upTeacherPassword(Integer id,String password);

}
